package net.zjitc.action.User.Index;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import net.zjitc.damain.Product.Product;
import net.zjitc.damain.category.Category;
import net.zjitc.service.Category.CategoryService;
import net.zjitc.service.Product.ProductService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/3/27.
 */
@Controller
@Scope("prototype")
public class IndexAction extends ActionSupport {
    @Resource
    private CategoryService categoryService;
    @Resource
    private ProductService productService;

    public String index(){
        List<Category> categoryList = categoryService.findAll();
//        ActionContext.getContext().put("categoryList",categoryList);
        ActionContext.getContext().getSession().put("categoryList",categoryList);

        List<Product> hlist = productService.findHotProductu(10);
        ActionContext.getContext().put("hlist",hlist);

        List<Product> newlist = productService.findNewProductu(10);
        ActionContext.getContext().put("newlist",newlist);
        return "index";
    }

}